<!-- 明细 -->
<template>
  <el-dialog
    title="明细"
    :visible.sync="dialogVisible"
    append-to-body
    width="60%"
  >
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      v-model="form"
      ref="crud"
      @search-change="searchChange"
      @search-reset="searchReset"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
      @row-update="rowUpdate"
    >
    </avue-crud>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">关 闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { statementInvoiceDetails } from "@/api/financial/index";

export default {
  data() {
    return {
      form: {},
      query: {},
      dialogVisible: false,
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      data: [],
      no: "",
    };
  },
  components: {},
  computed: {
    //是否已提交
    isSubmit() {
      return this.submit === 0;
    },
    option() {
      return {
        height: "auto",
        calcHeight: 30,
        tip: false,
        addBtn: false,
        menu: false,
        columnBtn: false,
        reserveSelection: true,
        searchShow: false,
        searchMenuSpan: 6,
        border: true,
        labelWidth: "120",
        menuWidth: "250",
        column: [
          {
            label: "货运订单",
            prop: "freightOrder",
            search: true,
            editDisplay: false,
          },
          {
            label: "需求单号",
            prop: "demandOrderNumber",
            editDisplay: false,
          },
          {
            label: "货运订单类型",
            prop: "freightOrderType",
            type: "select",
            searchLabelWidth: "100",
            editDisplay: false,
            props: {
              label: "value",
              value: "key",
            },
            search: true,
            dicUrl: `/api/blade-tms/common/SelectEnum?name=torType`,
            addDisplay: false,
          },
          {
            label: "承运商",
            prop: "carrierName",
            editDisplay: false,
            search: true,
          },
          {
            label: "结算类型",
            prop: "orderType",
            editDisplay: false,
          },
          {
            label: "费用类型",
            prop: "chargeText",
            editDisplay: false,
          },
          {
            label: "运费",
            prop: "money",
            editDisplay: false,
          },
          {
            label: "币别",
            prop: "docCurrency",
            editDisplay: false,
          },
          {
            label: "源位置街道",
            prop: "sourceLocationStreet",
            editDisplay: false,
          },
          {
            label: "目标位置街道",
            prop: "destinationStreet",
            editDisplay: false,
          },
          {
            label: "物料信息",
            prop: "materialInformation",
            editDisplay: false,
          },
          {
            label: "车牌号",
            prop: "licensePlateNumber",
            editDisplay: false,
          },
          {
            label: "司机",
            prop: "driver",
            editDisplay: false,
          },
          {
            label: "交货单号",
            prop: "deliverNo",
            editDisplay: false,
          },
          {
            label: "提单号",
            prop: "billOfLadingNumber",
            editDisplay: false,
          },
          {
            label: "源位置名称",
            prop: "startLocationName",
            editDisplay: false,
          },
          {
            label: "客户名称",
            prop: "customerName",
            editDisplay: false,
          },
          {
            label: "签收数量",
            prop: "num",
            editDisplay: false,
          },
          {
            label: "上传凭证",
            prop: "uploadVoucher",
            hide: true,
            showColumn: false,
            type: "upload",
            span: 24,
            listType: "picture-card",
            propsHttp: {
              res: "data",
              name: "originalName",
              url: "link",
            },
            action: "/api/blade-resource/oss/endpoint/put-file-attach",
            rules: [
              {
                required: true,
                message: "请上传凭证",
                trigger: "change",
              },
            ],
          },
        ],
      };
    },
  },
  methods: {
    open(no) {
      this.dialogVisible = true;
      this.no = no;
      this.onLoad(this.page);
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      let query = Object.assign(params, this.query);
      this.loading = true;
      statementInvoiceDetails({
        ...query,
        no: this.no,
        current: page.currentPage,
        size: page.pageSize,
      }).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.$nextTick(() => {
          this.$refs.crud.$refs.table.doLayout();
          this.$refs.crud.clearSort();
        });
      });
    },
  },
};
</script>

<style></style>
